<template>
  <div style="background-color: #858181; height: 83.375rem;">
    <div class="login">
      <div class="login-top">登 录</div>
      <van-form @submit="onSubmit">
        <van-field
          v-model="username"
          name="username"
          label="用户名"
          placeholder="用户名"
          :rules="[{ required: true, message: '请填写用户名' }]"
        />
        <van-field
          v-model="password"
          type="password"
          name="password"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
        />
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit">登录</van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>
<script>
import obj from '@/util/mixin0bj'
export default {
  mixins:[obj],
  data() {
    return {
      username:"",
      password:""
    }
  },
  methods: {
    onSubmit(value) {
      let token = {name:value.username,password: value.password}
      setTimeout(() => {
        localStorage.setItem('token', JSON.stringify(token))
        this.$router.push(this.$route.query.redirect)
      }, 1000)
    }
  }
}
</script>
<style>
.login{
  position: fixed;
  width: 100%;
  height: 25rem;
  background: white;
  top: 50%;
  margin-top: -18rem;
}
.login-top{
  height: 5rem;
  line-height: 5rem;
  text-align: center;
  color: rgb(12, 93, 159);
}

</style>
